Turn --avoid-dev-deps into a -Z unstable flag
authorXimin Luo <infinity0@pwned.gg>
Thu, 15 Feb 2018 14:31:12 +0000 (15:31 +0100)
committerXimin Luo <infinity0@pwned.gg>
Thu, 15 Feb 2018 14:31:12 +0000 (15:31 +0100)
src/bin/build.rs
src/cargo/core/features.rs
src/cargo/core/workspace.rs

index 9b576e922051429fcf3bc598aa58c69744713cf4..b388c36f5cea3499d15bfe7a2bbb4df752f63240 100644 (file)
@@ -12,7 +12,6 @@ pub struct Options {
     flag_features: Vec<String>,
     flag_all_features: bool,
     flag_no_default_features: bool,
-    flag_avoid_dev_deps: bool,
     flag_target: Option<String>,
     flag_manifest_path: Option<String>,
     flag_verbose: u32,
@@ -64,7 +63,6 @@ Options:
     --features FEATURES          Space-separated list of features to also build
     --all-features               Build all available features
     --no-default-features        Do not build the `default` feature
-    --avoid-dev-deps             Avoid installing dev-dependencies if possible
     --target TRIPLE              Build for the target triple
     --manifest-path PATH         Path to the manifest to compile
     -v, --verbose ...            Use verbose output (-vv very verbose/build.rs output)
@@ -101,7 +99,7 @@ pub fn execute(options: Options, config: &mut Config) -> CliResult {
 
     let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?;
     let mut ws = Workspace::new(&root, config)?;
-    if options.flag_avoid_dev_deps {
+    if config.cli_unstable().avoid_dev_deps {
         ws.set_require_optional_deps(false);
     }
 
index 414e6a4a8b6947aa7b967023c326d512c8103016..875f4e2dfa1d24ed8ad9b9e7029a0086e52a7fd1 100644 (file)
@@ -234,6 +234,7 @@ pub struct CliUnstable {
     pub unstable_options: bool,
     pub offline: bool,
     pub no_index_update: bool,
+    pub avoid_dev_deps: bool,
 }
 
 impl CliUnstable {
@@ -266,6 +267,7 @@ impl CliUnstable {
             "unstable-options" => self.unstable_options = true,
             "offline" => self.offline = true,
             "no-index-update" => self.no_index_update = true,
+            "avoid-dev-deps" => self.avoid_dev_deps = true,
             _ => bail!("unknown `-Z` flag specified: {}", k),
         }
 
index 00e93a92743636228a3f613bf03df3418e1e48e8..c2e1a3e4d624eda8e8f14a191506f19f26fe1dd7 100644 (file)
@@ -64,7 +64,8 @@ pub struct Workspace<'cfg> {
 
     // True if this workspace should enforce optional dependencies even when
     // not needed; false if this workspace should only enforce dependencies
-    // needed by the current configuration (such as in cargo install).
+    // needed by the current configuration (such as in cargo install). In some
+    // cases `false` also results in the non-enforcement of dev-dependencies.
     require_optional_deps: bool,
 }